package edu.pet.Servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import edu.pet.entity.Owner;
import edu.pet.DAO.PetDAO;

public class OwnerServlet extends HttpServlet {


	public OwnerServlet() {
		super();
	}


	public void destroy() {
		super.destroy();
	}

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		int id = Integer.parseInt(request.getParameter("id"));
		PetDAO dao = new PetDAO();
		Owner owner = dao.searchOwner(id);
		HttpSession session = request.getSession();
		session.setAttribute("owner", owner);
		response.sendRedirect("../user/ownerinfo.jsp");
	}

	public void init() throws ServletException {
	}

}
